import 'package:shared_preferences/shared_preferences.dart';
import '../api/api_client.dart';

Future<bool> isSessionValid() async {
  final prefs = await SharedPreferences.getInstance();
  final cookie = prefs.getString('cookie');
  if (cookie == null) {
    return false;
  }

  try {
    final response = await ApiClient.dio.get(ApiEndpoints.getLoginStatus);
    if (response.statusCode == 200 && response.data['success'] == 1) {
      return true;
    }
  } catch (e) {
    return false;
  }
  return false;
}
